{php include wl_template('common/header');}
<style type="text/css">
	.require{color:red;}
	.info{padding:6px;width:400px;margin:-20px auto 3px auto;text-align:center;}
</style>
<!--<span class="price" style="display:none;">0.01</span>-->
<ul class="nav nav-tabs">

	<li {if $op == 'display'}class="active"{/if}><a href="{php echo web_url('store/print', array('op' => 'display'))}">管理打印机</a></li>
	<li {if $op == 'post'}class="active"{/if}><a href="{php echo web_url('store/print', array('op' => 'post'))}">添加打印机</a></li>

</ul>
{if $op == 'base'}
	
	<div class="panel panel-default">
	<div class="panel-body table-responsive" style="padding: 0px;">
		<div class="main_bd">
        <div class="plugins_wrp">
            <dl>
                <dd>
                    <ul id="js_plugins">
						<li class="item_wrp" style="width: 100%;">
							<div class="plugin_item">
								<!--<div class="plugin_icon"><img src="{TG_URL_WRES}images/function/cashprint.png" style="cursor:pointer;"></div>-->
								<div  id="link-icon1" class="plugin_icon" >
									<div id="link-icon" style="display:none;width:100%;height:100%;position:absolute;background-color:rgba(0,0,0,0.3);cursor:pointer;">
										<img src="{TG_URL_WRES}images/3.svg"style="position:absolute;width:60%;left:20%;">
									</div>
									<img src="{TG_URL_WRES}images/function/cashprint.png" style="cursor:pointer;">
								</div>
								
								<div class="plugin_content">
									<h3 class="title">{$_W['page']['title']}</h3>
									<p class="desc" style="    width: 100%;">
									启用小票打印功能后，商品拼团成功或者单买支付成功后自动打印该商品至指定区域打印机！
										小票打印需备专用wifi打印机，其他打印机均无法使用！如需开启请联系客服！
										
									</p>
								</div>
							</div>
						</li>
					</ul>
                </dd>
            </dl>
        </div>
    </div>
	</div>
</div>
	{/if}
{if $op == 'post'}
	<form class="form-horizontal form" id="form1" action="" method="post" enctype="multipart/form-data">
		<input type="hidden" name="sid" value="{$sid}">
		<div class="main">
			<div class="panel panel-default">
				<div class="panel-heading">添加打印机</div>
				<div class="panel-body">
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require"> </span>是否启用云打印机</label>
						<div class="col-sm-9 col-xs-12">
							<label class="radio-inline">
								<input type="radio" value="1" name="status" {if $item['status'] == 1}checked{/if}> 启用
							</label>
							<label class="radio-inline">
								<input type="radio" value="0" name="status" {if $item['status'] == 0}checked{/if}> 不启用
							</label>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>云打印机名称</label>
						<div class="col-sm-9 col-xs-12">
							<input type="text" class="form-control" name="name" value="{$item['name']}" placeholder="填写打印机名称">
							<div class="help-block">如全国区域打印，请输入全国；如分区域打印，请输入XX市</div>
						</div>
					</div>
					
				<div class="form-group picmode" {if $item['mode']==2}style="display:block;"{else}style="display:none;"{/if}>
					<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">商户代码</label>
					<div class="col-xs-12 col-sm-8">
						<input type="text" class="form-control" name="member_code" value="{$item['member_code']}" placeholder="填写商户代码">
						<div class="help-block">在云打印机官网查看。</div>
					</div>
				</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label"><span class="require">* </span>机器号</label>
						<div class="col-sm-9 col-xs-12">
							<input type="text" class="form-control" name="print_no" value="{$item['print_no']}" placeholder="填写机器号">
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">云打印机key（API 密钥）</label>
						<div class="col-sm-9 col-xs-12">
							<input type="text" class="form-control" name="key" value="{$item['key']}" placeholder="填写打印机key（API 密钥）">
						</div>
					</div>
					<div class="form-group print_nums" >
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">打印联数</label>
						<div class="col-sm-9 col-xs-12">
							<input type="text" class="form-control" name="print_nums" value="{$item['print_nums']}">
							<div class="help-block">默认为1</div>
						</div>
					</div>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-9 col-xs-9 col-md-9">
					<input type="hidden" name="token" value="{$_W['token']}">
					<input name="submit" id="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
				</div>	
			</div>
		</div>
	</form>
	<script type="text/javascript">
		require(['util'], function(u){
			$('#post-add').click(function(){
				$('#tpl-container').append($('#tpl').html());
			});
		});
	</script>
{elseif $op == 'display'}
	<div class="clearfix">
		<form class="form-horizontal" action="" method="post">
			<div class="panel panel-default">
				<div class="panel-body table-responsive">
					<table class="table table-hover">
						<thead class="navbar-inner">
							<tr>
								<th>打印机名称</th>
								<th>机器号</th>
								<th>打印机key</th>
								
								<th>状态</th>
								<th style="width:150px; text-align:right;">状态/修改/删除</th>
							</tr>
						</thead>
						<tbody>
							{loop $data $item}
							<tr>
								<td>{$item['name']}</td>
								<td>{$item['print_no']}</td>
								<td>{$item['key']}</td>
								
								<td>
									{if $item['status'] == 1}
										<span class="label label-success">启用</span>
									{else}
										<span class="label label-danger">停用</span>
									{/if}
								</td>
								<td style="text-align:right;">
									 <!--<a href="{php echo $this->createWebUrl('print', array('op' => 'print_log', 'id' => $item['id']))}" class="btn btn-default btn-sm" title="打印记录" data-toggle="tooltip" data-placement="top" ><i class="fa fa-print"> </i></a>-->
								<a href="{php echo web_url('store/print',array('op' => 'post', 'id' => $item['id']))}" class="btn btn-default btn-sm" title="编辑" data-toggle="tooltip" data-placement="top" ><i class="fa fa-edit"> </i></a>
									<a href="{php echo web_url('store/print',array('op' => 'del', 'id' => $item['id']))}" class="btn btn-default btn-sm" title="删除" data-toggle="tooltip" data-placement="top" onclick="if(!confirm('删除后将不可恢复，确定删除吗?')) return false;"><i class="fa fa-times"> </i></a>
								</td>
							</tr>
							{/loop}
						</tbody>
					</table>
				</div>
			</div>
			
			<div class="form-group">
				<div class="col-sm-12">
					<a class="btn btn-success col-lg-2" href="{php echo web_url('store/print',array('op' => 'post'))}"/><i class="fa fa-plus-circle"> </i>  添加打印机</a>
				</div>
			</div>
			
		</form>
	</div>
{elseif $op == 'print_log'} 
	<div class="clearfix">
		<div class="panel panel-default">
			<div class="panel-heading">
				<span class="text-danger">{$item['name']}</span>
			</div>
			<div class="panel-body">
				<form class="form-horizontal form"
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">打印机状态：</label>
						<div class="col-sm-9 col-xs-12">
							<p class="form-control-static text-danger">{$status}</p>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div class="panel panel-info">
			<div class="panel-heading">筛选</div>
			<div class="panel-body">
				<form action="./index.php" method="get" class="form-horizontal" role="form">
					<input type="hidden" name="c" value="site">
					<input type="hidden" name="a" value="entry">
					<input type="hidden" name="m" value="str_takeout">
					<input type="hidden" name="do" value="manage">
					<input type="hidden" name="op" value="print_log">
					<input type="hidden" name="id" value="{$id}">
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单id</label>
						<div class="col-sm-4 col-xs-4 col-md-4">
							<input type="text" value="{$oid}" class="form-control" name="oid">
						</div>
						<div class="col-xs-12 col-sm-3 col-md-2 col-lg-1">
							<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div class="btn btn-success" style="margin-bottom:10px;" onclick="location.reload();"><i class="fa fa-refresh"></i> 刷新</div>
		<div class="panel panel-default">
			<div class="panel-body">
				<table class="table">
					<thead>
						<tr>
							<th>订单id</th>
							<th>预定人</th>
							<th>手机号</th>
							<th>打印状态</th>
							<th>打印时间</th>
							<th>删除</th>
						</tr>
					</thead>
					<tbody>
						{loop $data $da}
							<tr>
								<!-- <td><a title="查看订单" href="{php echo $this->createWebUrl('pnt', array('op' => 'orderdetail', 'id' => $da['oid']));}">{$da['oid']}</a></td> -->
								<td>{$da['username']}</td>
								<td>{$da['mobile']}</td>
								<td>
									{if $da['status'] == 1}
										<span class="label label-success">已打印</span>
									{else}
										<span class="label label-success">未打印</span>
									{/if}
								</td>
								<td>{php echo date('Y-m-d H:i:s', $da['addtime']);}</td>
								<td>
									<a href="{php echo $this->createWebUrl('manage', array('op' => 'log_del', 'id' => $da['id']));}" class="btn btn-default btn-sm" onclick="if(!confirm('确定删除吗')) return false;" title="编辑" data-toggle="tooltip" data-placement="top" ><i class="fa fa-times"></i></a>
								</td>
							</tr>
						{/loop}
					</tbody>
				</table>
			</div>
		</div>
		{$pager}
	</div>
{/if}
<script type="text/javascript">
	var linkicon=document.getElementById("link-icon");
		var linkicon2=document.getElementById("link-icon1");
		
		linkicon2.onmouseleave = function () {
			linkicon.style.setProperty( 'display', 'none' );
		}
		
		linkicon2.onmouseover = function () {
			linkicon.style.setProperty( 'display', 'block' );
		}
		
		linkicon.onclick=function (ev) {
			document.getElementById('detailimg').src='{TG_URL_WRES}images/function/xpdy.jpg';
			document.getElementById("detailname").innerHTML = "小票打印";
			document.getElementById("detailshow").style.setProperty("display","block");
		}
	require(['util'], function(u){
		$('.btn').hover(function(){
			$(this).tooltip('show');
		},function(){
			$(this).tooltip('hide');
		});
	});
</script>

{php include wl_template('common/footer');}